package com.tiandao.mofang.core.richang;

import com.tiandao.mofang.core.RobotSingleton;
import com.tiandao.mofang.core.role.BaseRole;
import com.tiandao.mofang.core.util.YiDong;
import com.tiandao.mofang.ui.MFFrame;

import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.Date;

/**
 *  日常:打坐
 *  完成时间 : 2020年8月17日22:05:02
 */
public class DaZuo implements Runnable{
    public static int HAO_NUM = 1;
    private static Robot robot = RobotSingleton.getInstance();

    public static void main(String[] args) {
//        YiDong.yfsxqdt(970,730,YiDong.QDT_HANG_ZHOU_Y);
        start();
    }
    @Override
    public void run() {
        int i = 1;
        while(i<=HAO_NUM){
            if(i==1){
                MFFrame.textArea.append(new Date()+":    第一个号开始!\n");
                start();
                MFFrame.textArea.append(new Date()+":    第一个号结束!\n");
            }
            if(i==2){
                try {
                    Thread.sleep(3000);
                    robot.keyPress(KeyEvent.VK_ALT);
                    Thread.sleep(200);
                    robot.keyPress(KeyEvent.VK_TAB);
                    robot.keyRelease(KeyEvent.VK_TAB);
                    Thread.sleep(200);
                    robot.keyRelease(KeyEvent.VK_ALT);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                MFFrame.textArea.append(new Date()+":    第二个号开始!\n");
                start();
                MFFrame.textArea.append(new Date()+":    第二个号结束!\n");
            }
            if(i==3){
                try {
                    Thread.sleep(3000);
                    robot.keyPress(KeyEvent.VK_ALT);
                    Thread.sleep(200);
                    robot.keyPress(KeyEvent.VK_TAB);
                    robot.keyRelease(KeyEvent.VK_TAB);
                    Thread.sleep(200);
                    robot.keyPress(KeyEvent.VK_TAB);
                    robot.keyRelease(KeyEvent.VK_TAB);
                    Thread.sleep(200);
                    robot.keyRelease(KeyEvent.VK_ALT);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                MFFrame.textArea.append(new Date()+":    第三个号开始!\n");
                start();
                MFFrame.textArea.append(new Date()+":    第三个号结束!\n");
            }
            if(i==4){
                try {
                    Thread.sleep(3000);
                    robot.keyPress(KeyEvent.VK_ALT);
                    Thread.sleep(200);
                    robot.keyPress(KeyEvent.VK_TAB);
                    robot.keyRelease(KeyEvent.VK_TAB);
                    Thread.sleep(200);
                    robot.keyPress(KeyEvent.VK_TAB);
                    robot.keyRelease(KeyEvent.VK_TAB);
                    Thread.sleep(200);
                    robot.keyPress(KeyEvent.VK_TAB);
                    robot.keyRelease(KeyEvent.VK_TAB);
                    Thread.sleep(200);
                    robot.keyRelease(KeyEvent.VK_ALT);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                MFFrame.textArea.append(new Date()+":    第四个号开始!\n");
                start();
                MFFrame.textArea.append(new Date()+":    第四个号结束!\n");
            }
            if(i==5){
                try {
                    Thread.sleep(3000);
                    robot.keyPress(KeyEvent.VK_ALT);
                    Thread.sleep(200);
                    robot.keyPress(KeyEvent.VK_TAB);
                    robot.keyRelease(KeyEvent.VK_TAB);
                    Thread.sleep(200);
                    robot.keyPress(KeyEvent.VK_TAB);
                    robot.keyRelease(KeyEvent.VK_TAB);
                    Thread.sleep(200);
                    robot.keyPress(KeyEvent.VK_TAB);
                    robot.keyRelease(KeyEvent.VK_TAB);
                    Thread.sleep(200);
                    robot.keyPress(KeyEvent.VK_TAB);
                    robot.keyRelease(KeyEvent.VK_TAB);
                    Thread.sleep(200);
                    robot.keyRelease(KeyEvent.VK_ALT);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                MFFrame.textArea.append(new Date()+":    第五个号开始!\n");
                start();
                MFFrame.textArea.append(new Date()+":    第五个号结束!\n");
            }
            i++;
        }
    }

    //开始的方法
    public static void start(){
        //按下M 去杭州
        try {
            Thread.sleep(5000);
            //跨地图御风神行
            YiDong.yfsxqdt(970,730,YiDong.QDT_HANG_ZHOU_Y);
            //传送到巴蜀
            Thread.sleep(15000);
            robot.keyPress(KeyEvent.VK_F);
            robot.keyRelease(KeyEvent.VK_F);
            Thread.sleep(1500);
            robot.mouseMove(250,545);
            Thread.sleep(1500);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            Thread.sleep(1500);
            robot.mouseMove(250,585);
            Thread.sleep(1500);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            Thread.sleep(1500);
            robot.mouseMove(250,625);
            Thread.sleep(1500);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            Thread.sleep(1500);
            robot.mouseMove(250,545);
            Thread.sleep(1500);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            //寻路到打坐点
            Thread.sleep(15000);
            robot.keyPress(KeyEvent.VK_6);
            robot.keyRelease(KeyEvent.VK_6);
            Thread.sleep(1500);
            YiDong.zouLu("1226","1371");
            Thread.sleep(60000);
            robot.keyPress(KeyEvent.VK_F);
            robot.keyRelease(KeyEvent.VK_F);
            Thread.sleep(1500);
            //F对话打坐
            robot.mouseMove(240,548);
            Thread.sleep(1500);
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
            BaseRole.rollRight();
            Thread.sleep(1500);
            robot.keyPress(KeyEvent.VK_7);
            robot.keyRelease(KeyEvent.VK_7);

            MFFrame.textArea.append(new Date()+":    打坐正在 执行!\n");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


}
